extends IEventActuator


class_name UsableSetter
"""
负责执行IUsableComponent接口
"""


## 需要操作的角色
@export var character: ICharacterComponent = null
## 需要挂载的功能
@export var usable: IUsableComponent = null


func __check_exports() -> Dictionary:
    return IComponent.merge({
        "character": IComponent.find_parent.bind(self, func(x): return x is ICharacterComponent, character),
        "usable": IComponent.find_child.bind(self, func(x): return x is IUsableComponent, usable),
    }, super.__check_exports())

func execute() -> void:
    var c: CharacterComponent = character.get_character()
    if c == null:
        return
    if usable.is_used():
        usable.cancel()
    else:
        usable.apply(c)
